/*
 * @Author: your name
 * @Date: 2024-05-23 11:13:45
 * @LastEditTime: 2024-05-23 11:17:51
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \.leetcode\122.买卖股票的最佳时机-ii.cpp
 */
/*
 * @lc app=leetcode.cn id=122 lang=cpp
 *
 * [122] 买卖股票的最佳时机 II
 */

// @lc code=start
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int result = 0;
        for(int i = 1; i < prices.size(); i++){
            result += max(prices[i]-prices[i-1], 0);
        }
        return result;
    }
};
// @lc code=end

